package com.alingrad.android.froyoengine.graphics.renderable;

import com.alingrad.android.froyoengine.collisions.CollisionMaskData;


public class Rectangle extends Primitive {
	private CollisionMaskData mData;
	
	public Rectangle(float width, float height) {
		super();
		float halfWidth = width / 2;
		float halfHeight = height / 2;
		float[] vertices = new float[4 * 3];
			vertices[0] = -halfWidth;
			vertices[1] = halfHeight;
			vertices[2] = 0;
			vertices[3] = -halfWidth;
			vertices[4] = -halfHeight;
			vertices[5] = 0;
			vertices[6] = halfWidth;
			vertices[7] = -halfHeight;
			vertices[8] = 0;
			vertices[9] = halfWidth;
			vertices[10] = halfHeight;
			vertices[11] = 0;
		short[] indices = new short[6];
			indices[0] = 0;
			indices[1] = 1;
			indices[2] = 2;
			indices[3] = 0;
			indices[4] = 2;
			indices[5] = 3;
		createVertexBuffer(vertices);
		createIndexBuffer(indices);
		mData = new CollisionMaskData((int)-halfWidth, (int)-halfHeight, (int)width, (int)height);
	}

	@Override
	public CollisionMaskData getCollisionMaskData() {
		return mData;
	}
}
